package hbt;

import hbt.HibernateUtil;
import org.hibernate.Session;
import org.hibernate.SessionFactory;


import modelo.OrdenCompra;


public class HibernateOrdenCompraDAO {
	private static HibernateOrdenCompraDAO instancia = null;
	private static SessionFactory sf = null;

	public static HibernateOrdenCompraDAO getInstancia(){
		if(instancia == null){
			sf = HibernateUtil.getSessionFactory();
			instancia = new HibernateOrdenCompraDAO();
		} 
		return instancia;
	}
	
	public void grabarOC(OrdenCompra oc){
		Session session = sf.openSession();
		session.beginTransaction();
		session.persist(oc);
		session.flush();
		session.getTransaction().commit();
		session.close();
	}

	public void eliminarOC(OrdenCompra oc) {
		Session session = sf.openSession();
		session.beginTransaction();
		session.delete(oc);
		session.flush();
		session.getTransaction().commit();
		session.close();
	}

	public void modificarOC(OrdenCompra oc) {
		Session session = sf.openSession();
		session.beginTransaction();
		session.update(oc);
		session.flush();
		session.getTransaction().commit();
		session.close();
		
	}
	
	public OrdenCompra  consultarOC(int idoc) {
		return null;
	}
	
	
}


